package iechecs;

public class Nat implements IConstantes, Comparable<Nat> {

    private int value;

    private Nat() {
        super();
    }

    public Nat(int value) {
        super();
        this.value = value;
    }

//******************************************************************************
    public Object getValue() {
        return new Integer(this.value);
    }

    public void setValue(int value) {
        this.value = value;
    }
//*******************************************************************************

    public void increment() {
        value++;
    }

    public void decrement() {
        value--;
    }

    public int add(int operand) {
        return this.value + operand;
    }

    public Nat add(Nat n) {
        return new Nat(value + n.value);
    }

    public void _add(int operand) {
        this.value += operand;
    }

    public void subtract(int operand) {
        this.value -= operand;
    }
//*************************************************************************

    public int intValue() {
        return value;
    }

    public Integer toInteger() {
        return new Integer(intValue());
    }

    //*****************************************************************************
    public static Nat parseInt(String s) {
        return new Nat(Integer.parseInt(s));
    }

    public static String toString(Nat n) {
        return Integer.toString(n.intValue());
    }

    @Override
    public boolean equals(Object obj) {
        super.equals(obj);
        Nat n = (Nat) obj;
        return value == n.value;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 97 * hash + this.value;
        return hash;
    }

    public boolean inf(Nat n) {
        return compareTo(n) == -1;
    }

    @Override
    public int compareTo(Nat n) {
        final int INF = -1;
        final int EQUAL = 0;
        final int SUP = 1;
        if (n.value == value) {
            return EQUAL;
        }
        if (value < n.value) {
            return INF;
        }
        if (value > n.value) {
            return SUP;
        }
        return 0;

    }
}
